package com.tuanbiao.ui.auth.adapter;

import android.text.TextUtils;

import androidx.annotation.NonNull;

import com.abiao.lib_utils.TimeUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.hzjq.data.minbao.entity.AuthEntity;
import com.tuanbiao.R;

import timber.log.Timber;

/**
 * @author abiao
 * @since 2022/4/22 17:05
 */
public class AuthListDetailsAdapter extends BaseQuickAdapter<AuthEntity.Lgs.Lg, BaseViewHolder> {
    public AuthListDetailsAdapter() {
        super(R.layout.item_auth_list_details);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder holder, AuthEntity.Lgs.Lg entity) {
        Timber.i("AuthListDetailsAdapter:" + entity);
        holder.setText(R.id.tv_serial_num, String.valueOf(holder.getLayoutPosition() + 1))
                .setText(R.id.tv_uid, entity.getUid());
        if(!TextUtils.equals(entity.getGzmcwxx(),"0")){
            String errorMsg = "已失效";
           if(TextUtils.equals(entity.getGzmcwxx(),"1")){
               errorMsg = "黑名单";
           } else if(TextUtils.equals(entity.getGzmcwxx(),"2")){
               errorMsg = "已使用";
           } else if(TextUtils.equals(entity.getGzmcwxx(),"3")){
               errorMsg = "无效UID";
           }
            holder.setText(R.id.tv_remark, errorMsg)
                       .setTextColorRes(R.id.tv_remark, R.color.textDanger);
        } else {
            if (TextUtils.isEmpty(entity.getYxq())) {
                holder.setText(R.id.tv_remark, "已失效")
                        .setTextColorRes(R.id.tv_remark, R.color.textDanger);
            } else {
                if (TimeUtils.string2Millis(entity.getYxq()) > TimeUtils.getNowMills()) {
                    holder.setText(R.id.tv_remark, "有效")
                            .setTextColorRes(R.id.tv_remark, R.color.textSuccess);
                } else {
                    holder.setText(R.id.tv_remark, "已失效")
                            .setTextColorRes(R.id.tv_remark, R.color.textDanger);
                }
            }
        }
    }
}
